<?php $this->jQuery()->onLoadCaptureStart()?>
    var CKEDITOR = window.parent.CKEDITOR;

    var okListener = function(ev) {
    	var module = $('#module').val();
    	var controller = $('#controller').val();
    	
	    var formData = $('#module_form_wrapper form').formSerialize();
	    formData = formData.replace('&', ' / ');
	    formData = formData.replace('=', ' / ');
       this._.editor.insertHtml(
       	  '<cite class="digitalus_module">/ ' +
       	  module + ' / ' + controller + ' / render / ' + formData + '</cite><p></p>' );
       CKEDITOR.dialog.getCurrent().removeListener("ok", okListener);
    };

    CKEDITOR.dialog.getCurrent().on("ok", okListener);

	$('#module_block').change(function(){
		var type = $(this).val()
    	var url = '/dig/editor/select-module/include/' + type;
    	
    	$.digitalusApi.request('dig','module','getModuleBlockDetails',{block: type}, function(response){
    		$('#controller').val(response.results.controller);
    		$('#module').val(response.results.module);
    	});
    	$.post(url, null, function(data){
    	    $('#module_form_wrapper').html(data);
    	});
		
	});	
<?php $this->jQuery()->onLoadCaptureEnd()?>

<?php 
echo $this->formHidden('module', $this->module);
echo $this->formHidden('controller', $this->controller);
?>
<p>The first step is selecting the type of block you would like to add...</p>
<p><?= $this->digPageSelectModuleBlock('module_block', $this->module_block)?></p>
<div id='module_form_wrapper'></div>